// 2024.11.4, jinfeng

#ifndef ZSTACK_ERROR_H
#define ZSTACK_ERROR_H

typedef enum
{
    RET_OK      = 0,
    // Reserved for line number
	RET_PARAM   = 0x10000 + 1,
    RET_MEM     = 0x10000 + 2,
    RET_IO      = 0x10000 + 3,
    RET_TIMEOUT = 0x10000 + 4,
    RET_FAILED  = 0xFFFFFFFF
} RETCODE;

#define GOTO_FAILED(cond)   \
    do                      \
    {                       \
        if (cond)           \
        {                   \
            goto FAILED;    \
        }                   \
    } while (0)

#define GOTO_FAILED_WITH_LINE(cond) \
    do                              \
    {                               \
        if (cond)                   \
        {                           \
            ret = __LINE__;         \
            goto FAILED;            \
        }                           \
    } while (0)

#define GOTO_FAILED_WITH_ERROR(cond, err)   \
    do                                      \
    {                                       \
        if (cond)                           \
        {                                   \
            ret = err;                      \
            goto FAILED;                    \
        }                                   \
    } while (0)
        
#endif